﻿using IServices.admin;
using Services.admin;
using Microsoft.AspNetCore.Mvc;
using Model.admin;
using Model.Common;
using srb.net.Controllers.Common;
using System.Collections.Generic;
using System.Threading.Tasks;
using Model;

namespace srb.net.Controllers.admin
{
    [Route("api/[Controller]/[action]")]
    [ApiController]
    public class AdminIntegralGradeController : BaseApiController
    {

        [HttpGet(Name = "GetAll")]
        public async Task<IActionResult> listAll()
        {
            return await ExecuteAsync(async () =>
            {
                IAdminIntegralGradeServices advertisementServices = new AdminIntegralGradeServices();
                return await advertisementServices.Query();
            }, "获取积分等级列表成功", "获取积分等级列表失败");
        }

        [HttpDelete(Name = "removeById")]
        public async Task<IActionResult> removeById(int id)
        {
            return await ExecuteAsync(async () =>
            {
                IAdminIntegralGradeServices advertisementServices = new AdminIntegralGradeServices();
                return await advertisementServices.DeleteById(id);
            }, "根据id删除积分等级成功", "根据id删除积分等级失败");
        }


        [HttpPost(Name = "save")]
        public async Task<IActionResult> save(AdminIntegralGrade integralGrade)
        {
            return await ExecuteAsync(async () =>
            {
                IAdminIntegralGradeServices advertisementServices = new AdminIntegralGradeServices();
                return await advertisementServices.Add(integralGrade);
            }, "新增积分等级成功", "新增积分等级失败");
        }

        [HttpPut(Name = "updateById")]
        public async Task<IActionResult> updateById(AdminIntegralGrade integralGrade)
        {
            return await ExecuteAsync(async () =>
            {
                IAdminIntegralGradeServices advertisementServices = new AdminIntegralGradeServices();
                return await advertisementServices.Update(integralGrade);
            }, "更新积分等级成功", "更新积分等级失败");
        }
    }
}
